﻿package bdz.projects.lavender.doi.utils
{
	import bdz.common.events.GenericEvent;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	/**
	 * ...
	 * @author ...
	 */
	public class DOIGlobalRender extends EventDispatcher
	{
		
		private static var instance:DOIGlobalRender;
		private var _timer:Timer;
		function DOIGlobalRender(se:SingletonEnforcer) {
			
		}
		private function initialize():void {
			_timer = new Timer(1000/60, 0);
			_timer.start();
			_timer.addEventListener(TimerEvent.TIMER, onTimerTick);
		}
		private function onTimerTick(evt:TimerEvent):void {
			dispatchEvent(new GenericEvent(GenericEvent.PROGRESS));
			evt.updateAfterEvent();
		}
		public static function getInstance():DOIGlobalRender {
			if (instance == null) {
				instance = new DOIGlobalRender(new SingletonEnforcer());
				instance.initialize();
			}
			return instance;
		}
		public function resume():void {
			_timer.start();
		}
		public function pause():void {
			_timer.stop();
		}
	}
	
}
/**
 * @private
 * 
 */
internal class SingletonEnforcer{}